home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / ckit210.zip / CKITDEMO.C < prev    next >
C/C++ Source or Header  |  1991-12-22  |  27KB  |  758 lines

  1. #include    "oldckit.h"          /* For version 2.0 CKit           */
  2. #include    "ckit.h"             /* Include CKIT Header file!      */
  3. #include    "ckitdemo.h"         /* Include file for demo          */
  4. #include    <fcntl.h>
  5. #pragma check_stack (off)
  6.  
  7.  
  8. short       OPENED;             /* Flag to know if open_door has been called  */
  9. short       CLOSED;             /* Flag to know if close_door has beeb called */
  10.  
  11. /******************************************************************************
  12.  *                     Start of Main Program                                  *
  13.  *****************************************************************************/
  14. main(int argc, char **argv) {
  15. short   result, i, j;
  16. size_t  max_bytes;
  17. char    *ptr, *des;
  18. /******************************************************************************
  19. *                        USER adjustments                                     *
  20. * You will need to set these according to how you want CKIT to handle certain *
  21. * options.  See the CKIT.DOC for more information                             *
  22. * These are all Ckit options, if not defined it will use defaults             *
  23. *******************************************************************************/
  24.     FORCEOFFHOOK = TRUE;             /* Default is FALSE                      */
  25.     USERSFILE = FALSE;               /* Default is FALSE anyway...            */
  26.     NO_FKEYS = FALSE;                /* Default is FALSE anyway...            */
  27.     DOTS = FALSE;                    /* Default is FALSE anyway...            */
  28.     silent = FALSE;                  /* Turn on local beeps(default is FALSE) */
  29.     logoff_color = (green);          /* Logoff msg to green (default=magenta) */
  30.     ck_logoff_msgs = &logoffs[0];    /* Set message table to demo msgs        */
  31.     ck_gen_msgs    = &ckit_msgs[0];  /* Set message table to demo msgs        */
  32.     set_kybd_time(2,6);              /* Beep time 2, timeout 6 minutes        */
  33.     OPENED = FALSE;
  34.     if (argc > 1) {                  /* (default is 3, 5 minutes)             */
  35.         strupr(argv[1]);
  36.         if(strstr(argv[1], "CHAIN.TXT")) {  /* Check if WWIV */
  37.             result = read_WWIV();    /* Ckit doesn't support WWIV directly    */
  38.             if(result) {             /* so we will read the chain file        */
  39.                 result -= 1;
  40.                 print_msg(result, ckit_errors);
  41.                 if(!result) {
  42.                     printf(" %s\n", argv[1]);
  43.                 }
  44.                 exit(1);
  45.             }
  46.             ck_NOSYSTEM = TRUE;     /* Tell Ckit not to expect a filename */
  47.             ptr = &ck_gen.port[0];
  48.         } else {
  49.             ptr = argv[1];              /* Assume it is a system supported    */
  50.             ck_NOSYSTEM = FALSE;
  51.         }
  52.         result = open_door(ptr,  argv[2]); /* Need arg2 for port:AAAA:X       */
  53.         if(!result) {
  54.             OPENED = TRUE;              /* Door has been opened               */
  55.             atexit(shut_down);          /* call shut_down at exit time        */
  56.         } else {
  57.             OPENED = FALSE;             /* Door open failed for some reason   */
  58.             print_msg(result-1, ckit_errors);
  59.             if(result <= 3) {
  60.                 printf("%s\n", argv[1]);
  61.             } else {
  62.                 if(result <= 6) {
  63.                     printf("%s\n", argv[2]);
  64.                 }
  65.             }
  66.             exit(1);
  67.         }
  68.         if(GENERIC) {       /* If generic.sys file, we need to know user name */
  69.             newline();
  70.             s_puts("Please enter first and last name (MAX 25) ->");
  71.             get_cmdline_raw(45);
  72.             strncpy(fullname, cmdline, sizeof(ck_fullname)-1);
  73.             i=1;
  74.             ptr = &ck_fullname[0];
  75.             des = &ck_firstname[0];     /* Copy firstname of fullname */
  76.             while((i < sizeof(ck_firstname)) && (*ptr != 0x20)) {
  77.                 *des++ = *ptr++;
  78.                 i++;
  79.             }
  80.             *des = '\0';        /* NULL terminate */
  81.         }
  82.         display_info();               /* Display user information  */
  83.         menu();                       /* Main program loop         */
  84.     }
  85.  return;
  86.  }
  87. /******************************************************************************
  88. *                       End of Main Program                                   *
  89. ******************************************************************************/
  90.  
  91. /******************************************************************************
  92. *                       Main Menu                                             *
  93. ******************************************************************************/
  94. void    menu(void) {
  95.     short   silent;
  96.  
  97.     silent = TRUE;
  98.     newline();
  99.     if(display_file("ckit.m")) {   /* If error display_file() return NON_ZERO */
  100.         newline();
  101.         printf("Error code %d\n", errno);
  102.     }
  103.     force_enter();
  104.     /* main command loop */
  105.     while(DUMP_USER != TRUE) {
  106.           /* prompt for input only if there is not a stacked command pending */
  107.         if ( strlen(cmdline) == 0) {
  108.             color(white);
  109.             newline();
  110.             s_puts("Main menu:\r\n");
  111.             color(red);
  112.         s_puts(" (I)  Display system information\r\n");
  113.             color(green);
  114.             s_puts(" (C)  Take a chance for more time online\r\n");
  115.             color(magenta);
  116.             s_puts(" (T)  Display a test pattern\r\n");
  117.             color(cyan);
  118.             s_puts(" (A)  Ansi graphics demo\r\n");
  119.             color(violet);
  120.             s_puts(" (D)  Display information on CKIT\r\n");
  121.             color(green);
  122.             s_puts(" (F)  Download CKIT.DOC using Zmodem \r\n");
  123.             color(yellow);
  124.             s_puts(" (M)  Color Mode On/Off \r\n");
  125.         color(red);
  126.             s_puts(" (Q)  Return to PCBoard\r\n");
  127.             color(green);
  128.             s_puts(" (G)  Logoff  (Disconnect)\r\n");
  129.             color(cyan);
  130.             s_puts("\r\n\
  131. While you are sitting here at the command line. Press some extended key\
  132. board \r\nkeys. If you are on the remote end using Qmodem, go into the DOORWAY\r\n\
  133. mode. Remember this is just a demo/usage for scan_code, so it's nothing \
  134. fancy.\r\n");
  135.             color(yellow);
  136.             do {
  137.                 newline();
  138.         display_time();
  139.                 color(green);
  140.                 s_puts("Command? ");
  141.                 get_cmdline();          /* read input into 'cmdline'  */
  142.  
  143.             } while((DUMP_USER != TRUE) && (strlen(cmdline) == 0) && (scan_code == 0));
  144.         }
  145.         if (DUMP_USER == TRUE) {
  146.             exit(1);
  147.         }
  148.         if (scan_code != 0) {
  149.             color(white);
  150.             read_scancode();
  151.         newline();
  152.         }
  153.         if (get_nextpar()) {  /* scan next parameter from cmdline into par */
  154.             newline();
  155.       /* process commands */
  156.             switch ( par[0] ) {
  157.                 case 'A':
  158.                 ansi_demo();
  159.                 break;
  160.                 case 'C':
  161.                 take_chance();
  162.                 break;
  163.                 case 'I':
  164.         display_info();
  165.                 break;
  166.                 case 'T':
  167.                 test_pattern();
  168.                 break;
  169.                 case 'D':
  170.                 color(cyan);
  171.                 strcpy(error_msg11, "\a\nUnable to locate CKIT.DOC");
  172.                 if(display_file(doc_filename)) {
  173.                     newline();
  174.                     printf("Error code %d\n", errno);
  175.                 };
  176.                 break;
  177.         case 'F':
  178.                 color(cyan);
  179.                 filexfer();
  180.                 break;
  181.                 case 'M':
  182.                 graphics ^= TRUE; /* Toggle graphics */
  183.                 ansi_ng |= TRUE;  /* Set ansi_ng (we only want to turn off color) */
  184.                 ck_set_ANSI(ansi_ng | graphics);
  185.                 break;
  186.                 case 'Q':
  187.                 option = EXITDOOR;
  188.                 return;
  189.                 case 'G':
  190.         option = LOGOFF;
  191.                 return;
  192.                 default:
  193.                 newline();